//
//  Any + DataCast.swift
//  Edaixi-iOS
//
//  Created by 刘树华 on 2017/12/4.
//  Copyright © 2017年 刘树华. All rights reserved.
//

import Foundation
import UIKit
func toInt (data:Any?) -> Int? {
    if let value = data as? Int {
        return value
    }else{
        return nil
    }
 
}

func toCGFloat(data:Any?) ->CGFloat?  {
    if let value = data as? CGFloat {
        return value
    }else{
        return nil
    }
}

func toDouble(data:Any?) -> Double? {
    if let value = data as? Double {
        return value
    }else{
        return nil
    }
}

func toFloat(data:Any?) -> Float? {
    if let value = data as? Float {
        return value
    }else{
        return nil
    }
}

func toUint(data:Any?) -> UInt? {
    if let value = data as? UInt {
        return value
    }else{
        return nil
    }
}

func toString(data:Any?) -> String? {
    if let value = data as? String {
        return value
    }else{
        return nil
    }
}

func toArr<T> (data:Any?) -> [T]? {
    if let value = data as? [T] {
        return value
    }else{
        return nil
    }
}

func toDictionary<T>(data:Any?) -> [T:T]? {
    if let value = data as? [T:T] {
        return value
    }else{
        return nil
    }
}

